import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
// import LoginView from '@/views/login/LoginView'
import SideLayout from '@/views/layout/Layout'
// 依次引入Vue VueRouter 
Vue.use(VueRouter)

const routes = [

  // 默认打开页面
  {
    path: '/',
    name: 'home',
    // redirect: '/login', // 默认子路由
    component: SideLayout,
  },
  // 登录时路由
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login/LoginView')
  },
  // 初始化自带的路由
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
